#include "mainwindow.h"
#include <QMessageBox>
#include <QSystemTrayIcon>//任务栏类
#include <QMessageLogger>
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
   init();
}
MainWindow::~MainWindow(){
}
void MainWindow::init(){
    log = new QMessageLogger();
    setGeometry(200, 200, 800, 600);
    setWindowTitle("菜单");
    fileMenu = menuBar()->addMenu(tr( "文件" ));
    editMenu = menuBar()->addMenu("编辑");
    helpMenu = menuBar()->addMenu(tr("帮助"));
    //填充菜单子节点
    newAct = new QAction(QIcon( "resources/new.png" ), tr( "新建" ), this );
    newAct->setShortcut(tr("Ctrl+N" ));
    newAct->setStatusTip(tr("新建文件" ));
    connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
    fileMenu->addAction(newAct);
    fileMenu->addSeparator();

    //判断系统是否支持托盘图标
    if(!QSystemTrayIcon::isSystemTrayAvailable())
    {
        QMessageLogger log;
        log.warning("不支持托盘图标");
        return;
    }
    log->info("不支持托盘图标");


}

void MainWindow::newFile(){
    QMessageBox::warning(this,tr("Warning"),
    tr("创建新文件?"),
    QMessageBox::Yes | QMessageBox::Default,
    QMessageBox::No);

}
